<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]-->
<!--[if IE 7]> <html class="lt-ie9 lt-ie8" lang="en"> <![endif]-->
<!--[if IE 8]> <html class="lt-ie9" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html lang="en"> <!--<![endif]-->
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <title>Login Form</title>
  <link rel="stylesheet" href="{path}/statics/css/style.css">

</head>
<body>

  <section class="container">
    <div class="login">
      <h1>管理员登录</h1>
      <form method="post" action="" id="formId">
        <p><input type="text" name="account" value="" placeholder="账号" id = "accountId"></p>
        <p><input type="password" name="password" value="111" placeholder="密码" id = "pwdId"></p>
        <p class="remember_me">
          <label>
            <input type="checkbox" name="remember_me" id="remember_me">
            记住密码
          </label>
        </p>
        <p class="submit"><input type="button" name="commit" value="登录" id="loginBtn"></p>
      </form>
    </div>

  </section>
	
	<script type="text/javascript" src="${path}/statics/js/jquery-1.8.3.js"></script>
	<script type="text/javascript">
		
		$("#loginBtn").click(function(){
			
			var account = $("#accountId").val();
			var pwd = $("#pwdId").val();
			
			if(account.length == 0){
				alert("账号不能为空");
				return;
			}
			if(pwd.length == 0){
				alert("密码不能为空");
				return;
			}
			
			$.post("${path}/loginCtl/login",$("#formId").serialize(),function(res){
				
				if(res == 0){
					location.replace("${path}/loginCtl/toSuccess");
				}else if(res == 1){
					alert("账号或密码错误");
				}else{
					alert("系统繁忙，请稍后");
				}
			});
		});
		
	
	</script>
	
</body>
</html>
